package com.example.teaching_server.entity;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.*;

/**
 * 年级实体类
 *
 * @author Teaching Server
 * @since 1.0.0
 */
@Getter
@Setter
@ToString
@EqualsAndHashCode(of = "gradeId")
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "grades", indexes = {
        @Index(name = "idx_grade_name", columnList = "grade_name"),
        @Index(name = "idx_grade_sort", columnList = "sort_order")
})
public class Grade {

    /**
     * 年级ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "grade_id")
    private Long gradeId;

    /**
     * 年级名称
     */
    @NotBlank(message = "年级名称不能为空")
    @Size(max = 50, message = "年级名称长度不能超过50个字符")
    @Column(name = "grade_name", nullable = false, unique = true, length = 50)
    private String gradeName;

    /**
     * 排序序号
     */
    @Column(name = "sort_order")
    @Builder.Default
    private Integer sortOrder = 0;

    /**
     * 年级描述
     */
    @Size(max = 200, message = "年级描述长度不能超过200个字符")
    @Column(name = "description")
    private String description;
}
